All Questions
231 questions
3votes
5answers
645views
removing braces statements containing nested braces inside
A typical latex problem: \SomeStyle{\otherstyle{this is the \textit{nested part} some more text...}} Now I want to remove all \SomeStyle{...} but not the content. Content contains nested braces. The ...
1vote
3answers
125views
sed to replace in a file, with both old and new strings in files
I want to automatically comment out a code block in PHP file, as below: The original block: // Enable all errors ini_set('display_startup_errors', 1); ini_set('display_errors', 1); ...
1vote
2answers
52views
replace both filename and filename's content relying solely on pattern found on the name-of-the-file
I'd like to know if it's possible to replace both filename.ext and a matched pattern inside its content regarding a pattern founded on the filename itself using sed (and grep also, maybe?). Let me ...
-3votes
2answers
97views
How can find special row and replace special strings
I wrote a todo list script with "add","clear" and "find" argument. I need to pass a "done" argument and script find related row and replace its first column ...
0votes
4answers
801views
sed: Replacing successful as the condition
I bumped into an excellent use of sed to do replacing, and use its successful state as the condition to print the line: $ seq 3 | sed -n 's/2/B/ p' B I'm wondering if this short form can be extended ...
0votes
3answers
613views
Adding 10 whitespace characters using sed
I have written a script that replaces a string, but I need to add the 10 whitespace characters back. I can add it back by pressing space 10 times, and that works, but this looks hideous in my script. ...
1vote
4answers
367views
Insert one file's content into another file and replace it between pattern
I have a file1.html: <!doctype html> <html> <head> </head> <body> text <!-- start-replacing --> <p>more text1</p> <p>more text2</p> ...
1vote
1answer
329views
Find and replace a special pattern for all files in a folder
I have a series of files in a common bioinformatic format (FASTA) that consist of a string of: 1 special character ">", text as the sample name (length of the string varies, can include ...
2votes
3answers
5kviews
Replace empty string with text using sed or similar tool
Is it possible to replace an empty string with some text using sed or similar tool? sed 's/^$/sometext/' will match an empty line but that is not what I am looking for. I thought that sed 's//...
0votes
1answer
187views
Find and replace everything inside bracket using unix shell - several lines
I need to find and replace a big part of a json file using shell. For exemple I have this file : { "Balise1": true, "Balise2": true, "OtherThingEnabled": false, ...
1vote
2answers
166views
sed -Extended RegEx question here
I feel dumb as a sack of hammers asking this here, but it's been a long day and I simply CANNOT figure out what I'm doing wrong here. I have a file; we'll call it textfile.txt. It's contents are (in ...
1vote
1answer
57views
Show application list with description, ommitting "nothing appropriate"
I've been working on a script with a variety of functions. I'm trying to add a function that show's the output of the whatis command for all applications in the "/usr/share/applications" ...
2votes
3answers
548views
Sed replace the middle string
I have this this String 22<>22 And i have this list test dev too The output should be like 22test22 22dev22 etc.. This is the commands i use for do that cat list | sed 's/$/22/g' | sed 's/^/...
2votes
2answers
818views
Delete multiline blocks with sed non-greedy
How can one remove code blocks starting with /** START */ and ending with /** END */ using sed non-greedily considering that code blocks are multiline and empty lines may occur within START-END blocks?...
0votes
1answer
110views
uncomment the line upon search string while ignoring case in a file
Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...